CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

IF (NOT TARGET LIB::H)
    ADD_LIBRARY(LIB::H INTERFACE IMPORTED)
    TARGET_COMPILE_DEFINITIONS(LIB::H INTERFACE "ZLIB_WINAPI")
    TARGET_INCLUDE_DIRECTORIES(LIB::H INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/windows/include")
ENDIF ()

IF (NOT TARGET LIB::MINIZIP)
    ADD_LIBRARY(LIB::MINIZIP OBJECT IMPORTED)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/windows/src SOURCES)
    TARGET_SOURCES(LIB::MINIZIP INTERFACE "${SOURCES}")
ENDIF ()

IF (NOT TARGET LIB::ZLIB)
    FIND_LIBRARY(LIB_ZLIB NAMES zlibstatic PATHS ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib NO_DEFAULT_PATH)
    ADD_LIBRARY(LIB::ZLIB STATIC IMPORTED)
    SET_TARGET_PROPERTIES(LIB::ZLIB PROPERTIES IMPORTED_LOCATION "${LIB_ZLIB}")
ENDIF ()

IF (NOT TARGET LIBRARIES::MINIZLIB)
    ADD_LIBRARY(LIBRARIES::MINIZLIB INTERFACE IMPORTED GLOBAL)
    TARGET_LINK_LIBRARIES(LIBRARIES::MINIZLIB INTERFACE
            LIB::H
            LIB::MINIZIP
            LIB::ZLIB)
ENDIF ()